var http = require('http');
var port = 80;
var ip = '127.0.0.1';
var fs = require('fs');
http.createServer(function (request, response) {
	// console.log(request.headers['user-agent'])
	// 发送 HTTP 头部 
	// HTTP 状态值: 200 : OK
	// 内容类型: text/plain
	// response.writeHead(403,"zhao budao", {'Content-Type': 'text/html'});
	response.statusCode = 200;
	response.statusMessage = "It's not find";
	response.setHeader('Server','private server');
	response.setHeader('Content-Type', 'text/html');
	// 发送响应数据 "Hello World"
	var s = ''
	// s+="<head>"
	// s+="<style>"
	// s+="html{background-color: #eee;}"
	// s+="h1{text-align: center;}"
	// s+="a{text-decoration: none;color:#999;margin-left:50px;font-size:20px;font-weight:bold;padding:5px;display:inline-block;border-radius: 10px;}"
	// s+=".a2{margin-left:20px;}"
	// s+="a:hover{color:#333;border-bottom: 1px solid #999;;background-color: #fff;}"
	// s+="</style>"
	// s+="</head>"
	// s+="<body>"
	if (request.url=='/about.html') {
		s+=fs.readFileSync('./about.html');
	}else{
		s+=fs.readFileSync('./index.html');
	}
	// s+="<a class='a1' href='index.html'>主页</a><a class='a2' href='about.html'>关于</a>"
	// s+="</body></html>"
	response.end(s);
}).listen(port);

// 终端打印如下信息
console.log('Server running at http://%s:%s/',ip,port);